package com.winshare.saleAssistant.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.winshare.saleAssistant.domain.dto.req.PageQueryDTO;
import com.winshare.saleAssistant.domain.dto.req.UserQueryDTO;
import com.winshare.saleAssistant.util.PageFactory;
import com.winshare.saleAssistant.model.TUser;
import com.winshare.saleAssistant.service.ITUserService;
import com.winshare.saleAssistant.util.LogicResponse;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/sys/tUser")
public class TUserController {

    @Resource(name = "TUserServiceImpl")
    private ITUserService tUserService;

    /**
     * 获取列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(@RequestBody UserQueryDTO userQueryDTO) {
        return LogicResponse.success(tUserService.selectByCondition(userQueryDTO));
    }

    /**
     * 获取未绑定的学校数据
     */
    @RequestMapping(value = "/notMatches")
    @ResponseBody
    @ApiOperation(value = "获取未绑定的学校数据(分页)", notes = "", httpMethod = "POST")
    public Object getNotMatchUserByPage(@RequestBody PageQueryDTO pageQueryDTO) {
        return LogicResponse.success(tUserService.getNotMatchUserByPage(pageQueryDTO));
    }

    /**
     * 根据学校名字修改学校编号
     */
    @RequestMapping(value = "/updateUserSchoolCode")
    @ResponseBody
    @ApiOperation(value = "根据学校名字修改学校编号", notes = "", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "schoolName", value = "学校名字", required = true),
            @ApiImplicitParam(name = "schoolCode", value = "学校编号", required = true),
    })
    public Object getNotMatchUserByPage(@RequestParam String schoolName, @RequestParam String schoolCode) {
        return LogicResponse.success(tUserService.updateUserSchoolCode(schoolName, schoolCode));
    }
}
